{include file="public/head"/}
<style type="text/css">
    .layui-elem-quote{padding: 10px !important;}
</style>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"> 订单【{$order.id}】【{$order.order_sn}】详情</div>
                <div class="layui-card-body" pad15>

                    <blockquote class="layui-elem-quote"><b>订单信息</b></blockquote>
                    <table class="layui-table" style="margin-bottom: 10px;">
                        <thead>
                        <tr>
                            <th>订单编号</th>
                            <th>订单单号</th>
                            <th>订单类型</th>
                            <th>活动类型</th>
                            {if $order['type']==1}
                            <th>核销类型</th>
                            <th>核销码</th>
                            <th>使用期限</th>
                            {/if}
                            <td>订单状态</td>
                            <th>商品总价</th>
                            <th>运费</th>
                            <!--Totag 隐藏积分抵扣-->
<!--                            <th>使用{:config('self.user_coin_title')}</th>-->
<!--                            <th>{:config('self.user_coin_title')}抵扣</th>-->
                            <th>订单总价</th>
                            <th>商家结算</th>
                            <th>买家奖励{:config('self.user_coin_title')}</th>
                            <th>下单时间</th>
                            <th>完成时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>{$order.id}</td>
                            <td>{$order.order_sn}</td>
                            <td>{:get_base_type(2,$order['type'])}</td>
                            <td>{:get_goods_activity_type(2,$order['activity_type'])}</td>
                            {if $order['type']==1}
                            <td>{:get_goods_verify_type(2,$order['verify_type'])}</td>
                            <td>{$order.verify_code}</td>
                            <td>
                                {if $order['is_expire']==0}
                                <font style="color:#FF5722">永久有效</font>
                                {elseif $order['is_expire']==1/}
                                <font style="color:#1E9FFF">{:date('Y-m-d H:i:s',$order['expire_time'])}</font>
                                {else/}
                                <font style="color:#009688">支付后{$order['expire_day']}天内</font>
                                {/if}
                            </td>
                            {/if}

                            <td>{:get_order_status($order)}</td>

                            <td>{$order.goods_price}</td>
                            <td>{$order.dispatch_price}</td>
                            <!--Totag 隐藏积分抵扣-->
<!--                            <td>{$order.coin}</td>-->
<!--                            <td>{$order.coin_deduct}</td>-->
                            <td>{$order.order_price}</td>
                            <td>{$order.merch_price}</td>
                            <td>{$order.coin_send}</td>
                            <td>{$order.create_time|toDate}</td>
                            <td>{$order.receive_time|toDate}</td>
                            <td>
                                {if $order['status']==1}
                                {if $order['type']==1}
                                <a class="layui-btn layui-btn-xs" layadmin-event="doVerify">确认核销</a>
                                {else/}
                                <a class="layui-btn layui-btn-xs" layadmin-event="doSend">确认发货</a>
                                {/if}
                                {/if}

                                {if $order['status']==2}
                                {if $order['type']==2}
                                <a class="layui-btn layui-btn-xs" layadmin-event="doSend">修改发货</a>
                                <a class="layui-btn layui-btn-normal layui-btn-xs" layadmin-event="doReceive">确认收货</a>
                                {/if}
                                {/if}

                                {if $order['type']==2&&($order['status']>=2 || $order['old_status']>=2)}
                                <a class="layui-btn layui-btn-warm layui-btn-xs" layadmin-event="sendInfo">查看物流</a>
                                {/if}

                                {if $order['type']==1&&($order['status']>=1 || $order['old_status']>=1)}
                                <a class="layui-btn layui-btn-danger layui-btn-xs" layadmin-event="verifyInfo">核销记录</a>
                                {/if}

                                {if $order['status']==-2}
                                <a class="layui-btn layui-btn-xs" layadmin-event="onlineRefund">线上退款</a>
                                <a class="layui-btn layui-btn-normal layui-btn-xs" layadmin-event="offlineRefund">线下退款</a>
                                <a class="layui-btn layui-btn-danger layui-btn-xs" layadmin-event="rejectRefund">驳回退款</a>
                                {/if}

                                {if $order['status']==-4}
                                <a class="layui-btn layui-btn-xs" layadmin-event="confirmChange">确认换货</a>
                                <a class="layui-btn layui-btn-danger layui-btn-xs" layadmin-event="rejectChange">驳回换货</a>
                                {/if}

                                {if $order['status']==-1}
                                <a class="layui-btn layui-btn-danger layui-btn-xs" layadmin-event="del">删除</a>
                                {/if}
                            </td>
                        </tr>
                        </tbody>
                    </table>

                    <blockquote class="layui-elem-quote"><b>买家/商家</b></blockquote>
                    <table class="layui-table" style="margin-bottom: 10px;">
                        <thead>
                        <tr>
                            <th>会员编号</th>
                            <th>昵称</th>
                            <th>注册手机</th>
                            <th>买家备注</th>
                            <th>商家编号</th>
                            <th>商家名称</th>
                            <th>联系方式</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>{$order.uid}</td>
                            <td>{$user.nickname}</td>
                            <td>{$user.mobile}</td>
                            <td>{$order.note|default='无'}</td>
                            <td>{$order.merch_id}</td>
                            <td>{$merch.title}</td>
                            <td>{$merch.mobile}</td>
                        </tr>
                        </tbody>
                    </table>

                    {if !in_array($order['status'],[-1,0])}
                    <blockquote class="layui-elem-quote"><b>支付信息</b></blockquote>
                    <table class="layui-table" style="margin-bottom: 10px;">
                        <thead>
                        <tr>
                            <th>支付方式</th>
                            <th>支付单号</th>
                            <th>支付金额</th>
                            <th>支付时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>{:get_pay_type(2,$order['pay_type'])}</td>
                            <td>
                                {:show_transaction_id($order['pay_type'],$order['transaction_id'])}
                            </td>
                            <td>￥{$order.pay_price}</td>
                            <td>{$order.pay_time|toDate}</td>
                        </tr>
                        </tbody>
                    </table>
                    {/if}

                    {if $order['type']==2}
                    <blockquote class="layui-elem-quote"><b>发货信息</b></blockquote>
                    <table class="layui-table" style="margin-bottom: 10px;">
                        <thead>
                        <tr>
                            <th>收货人</th>
                            <th>收货手机</th>
                            <th>收货地址</th>
                            <th>发货快递</th>
                            <th>快递单号</th>
                            <th>发货时间</th>
                            <th>收货时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>{$order.send_name}</td>
                            <td>{$order.send_mobile}</td>
                            <td>{$order.send_address}</td>
                            <td>{$order.send_express}</td>
                            <td>{$order.send_sn}</td>
                            <td>{$order.send_time|toDate}</td>
                            <td>{$order.receive_time|toDate}</td>
                            <td>
                                {if $order['type']==2&&($order['status']>=2 || $order['old_status']>=2)}
                                <a class="layui-btn layui-btn-warm layui-btn-xs" layadmin-event="sendInfo">查看物流</a>
                                {/if}
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    {/if}

                    {if $order['status']==-4 || $order['is_change']}
                    <blockquote class="layui-elem-quote"><b>换货信息</b></blockquote>
                    <table class="layui-table" style="margin-bottom: 10px;">
                        <thead>
                        <tr>
                            <th>补充描述</th>
                            <th>凭证图片</th>
                            <th>申请换货时间</th>
                            {if $order['change_over_time']>0}
                            <th>换货处理时限</th>
                            {/if}
                            <th>确认换货时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>{$order_change.note}</td>
                            <td>
                                {foreach $order_change['imgs'] as $item}
                                <img src="{$item}" style="width:50px;height:50px;" onclick="layer.tips('<div style=\'background-color: #fff;\'><img style=\'max-width: 350px;\' src=\'{$item}\'></div>',this,{tips: [1, '#fff'],time:-1,closeBtn:1,area: ['auto', 'auto']});">
                                {/foreach}
                            </td>
                            <td>{$order.change_apply_time|toDate}</td>
                            {if $order['change_over_time']>0}
                            <td style="color: red">{$order.change_over_time|toDate}</td>
                            {/if}
                            <td>{$order.change_time|toDate}</td>
                        </tr>
                        </tbody>
                    </table>
                    {/if}

                    {if in_array($order['status'],[-2,-3])}
                    <blockquote class="layui-elem-quote"><b>退款信息</b></blockquote>
                    <table class="layui-table" style="margin-bottom: 10px;">
                        <thead>
                        <tr>
                            <th>部分退款</th>
                            <th>退款原因</th>
                            <th>补充描述</th>
                            <th>凭证图片</th>
                            <th>申请退款时间</th>
                            {if $order['refund_over_time']>0}
                            <th>退款处理时限</th>
                            {/if}
                            <th>退款单号</th>
                            <th>退款金额</th>
                            <th>退款时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>
                                {if $order['is_some_refund']}
                                部分退款，未使用的次数退款，已使用次数结算给商家
                                {else/}
                                全额退款
                                {/if}
                            </td>
                            <td>{$order.refund_reason}</td>
                            <td>{$order_refund.note}</td>
                            <td>
                                {foreach $order_refund['imgs'] as $item}
                                <img src="{$item}" style="width:50px;height:50px;" onclick="layer.tips('<div style=\'background-color: #fff;\'><img style=\'max-width: 350px;\' src=\'{$item}\'></div>',this,{tips: [1, '#fff'],time:-1,closeBtn:1,area: ['auto', 'auto']});">
                                {/foreach}
                            </td>
                            <td>{$order.refund_apply_time|toDate}</td>
                            {if $order['refund_over_time']>0}
                            <td style="color: red">{$order.refund_over_time|toDate}</td>
                            {/if}
                            <td>
                                {:show_refund_sn($order)}
                            </td>
                            <td>
                                {if $order['activity_type']==1}
                                ￥{$order.refund_money}
                                {else/}
                                {:config('self.user_coin_title')}{$order.refund_money}
                                {/if}
                            </td>
                            <td>{$order.refund_time|toDate}</td>
                        </tr>
                        </tbody>
                    </table>
                    {/if}


                    <blockquote class="layui-elem-quote"><b>佣金</b></blockquote>
                    <table class="layui-table" style="margin-bottom: 10px;">
                        <thead>
                        <tr>
                            <th>{:get_user_distributor_level(3,2)}直推奖</th>
                            <th>{:get_user_team_level(3,2)}</th>
                            <th>{:get_user_team_level(3,3)}</th>
                            <th>{:get_user_team_level(3,4)}</th>
                            <th>{:get_agent_level(3,1)}</th>
                            <th>{:get_agent_level(3,2)}</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>
                                {if $order['direct_id']}
                                {php}$direct_user = app\common\model\Users::cacheNick($order['direct_id']);{/php}
                                <p>编号：{$order.direct_id} - {$direct_user.mobile} - {$direct_user.nickname}</p>
                                {/if}
                                <p>{$order.direct_price}</p>
                            </td>
                            <td>
                                {if $order['team2_id']}
                                {php}$team2_user = app\common\model\Users::cacheNick($order['team2_id']);{/php}
                                <p>编号：{$order.team2_id} - {$team2_user.mobile} - {$team2_user.nickname}</p>
                                {/if}
                                <p>{$order.team2_price}</p>
                            </td>
                            <td>
                                {if $order['team3_id']}
                                {php}$team3_user = app\common\model\Users::cacheNick($order['team3_id']);{/php}
                                <p>编号：{$order.team3_id} - {$team3_user.mobile} - {$team3_user.nickname}</p>
                                {/if}
                                <p>{$order.team3_price}</p>
                            </td>
                            <td>
                                {if $order['team4_id']}
                                {php}$team4_user = app\common\model\Users::cacheNick($order['team4_id']);{/php}
                                <p>编号：{$order.team4_id} - {$team4_user.mobile} - {$team4_user.nickname}</p>
                                {/if}
                                <p>{$order.team4_price}</p>
                            </td>
                            <td>
                                {if $order['agent1_id']}
                                {php}$agent1 = app\common\model\Agent::getInfo($order['agent1_id']);{/php}
                                <p>编号：{$order.agent1_id} - {$agent1.title}</p>
                                {/if}
                                <p>{$order.agent1_price}</p>
                            </td>
                            <td>
                                {if $order['agent2_id']}
                                {php}$agent2 = app\common\model\Agent::getInfo($order['agent2_id']);{/php}
                                <p>编号：{$order.agent2_id} - {$agent2.title}</p>
                                {/if}
                                <p>{$order.agent2_price}</p>
                            </td>
                        </tr>
                        </tbody>
                    </table>


                    <blockquote class="layui-elem-quote"><b>订单商品</b></blockquote>
                    <table class="layui-table">
                        <thead>
                            <tr>
                                <th>商品编号</th>
                                <th>名称</th>
                                <th>缩略图</th>

                                <th>规格标识</th>
                                <th>规格</th>
                                <th>单价</th>

                                <th>原价</th>
                                <!--Totag 隐藏积分抵扣-->
<!--                                <th>可用{:config('self.user_coin_title')}比例</th>-->
                                <th>会员优惠比例</th>
                                <th>购买数量</th>
                                {if $order['verify_type']==2}
                                <th>剩余数量</th>
                                {/if}
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $order_goods as $og}
                            <tr>
                                <td>{$og.goods_id}</td>
                                <td>{$og.title}</td>
                                <td>
                                    <img src="{$og.thumb}" style="width:50px;height:50px;" onclick="layer.tips('<div style=\'background-color: #fff;\'><img style=\'max-width: 300px;\' src={$og.thumb}></div>',this,{tips: [1, '#fff'],time:-1,closeBtn:1,area: ['auto', 'auto']});">
                                </td>

                                <td>{$og.sku}</td>
                                <td>{$og.spec_item_title}</td>
                                <td>{$og.price}</td>
                                <td>{$og.original_price}</td>
                                <!--Totag 隐藏积分抵扣-->
<!--                                <td>{$og.coin_percent}%</td>-->
                                <td>{$og.vip_percent}%</td>
                                <td>{$og.num}{$og.unit}</td>
                                {if $order['verify_type']==2}
                                <td>{$og.leave_num}{$og.unit}</td>
                                {/if}
                            </tr>
                            {/foreach}
                        </tbody>
                    </table>

                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/foot"/}
<script>
    layui.config({
        base: '__LAYADMIN__/',
        version: 20220407
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index'],function(){
        var $=layui.$,admin=layui.admin;

        var id = "{$order.id}";

        //删除订单
        admin.events.del = function (othis) {
            layer.confirm('确定删除此订单吗？删除后不可恢复', function(){
                layer.closeAll('dialog');
                admin.req({
                    url: '{:url(\'Order/del\')}'
                    , type: 'post'
                    , data: {id:id}
                    , success: function (res) {
                        if(res.code==0){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                                parent.layer.closeAll("iframe");
                                //刷新父页面
                                parent.tableIn.reload();
                            });
                        }
                    }
                });
            });
        };

        //确认/修改发货
        admin.events.doSend = function (othis) {
            var index = layer.open({
                type: 2,
                content: '{:url(\'Order/doSend\')}?id=' + id,
                area: ['50%', '80%'],
                maxmin: true
            });
            //layer.full(index);
        };

        //确认收货
        admin.events.doReceive = function (othis) {
            layer.confirm('确定订单已收货吗？操作不可逆转', function(){
                layer.closeAll('dialog');
                admin.req({
                    url: '{:url(\'Order/doReceive\')}'
                    , type: 'post'
                    , data: {id:id}
                    , success: function (res) {
                        if(res.code==0){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                                window.location.reload();
                                //刷新父页面
                                parent.tableIn.reload();
                            });
                        }
                    }
                });
            });
        };

        //发货物流信息
        admin.events.sendInfo = function (othis) {
            var index = layer.open({
                type: 2,
                content: '{:url(\'Order/sendInfo\')}?id=' + id,
                area: ['50%', '80%'],
                maxmin: true
            });
            //layer.full(index);
        };

        //确认核销
        admin.events.doVerify = function (othis) {
            var index = layer.open({
                type: 2,
                content: '{:url(\'Order/doVerify\')}?id=' + id,
                area: ['50%', '80%'],
                maxmin: true
            });
            //layer.full(index);
        };

        //核销记录
        admin.events.verifyInfo = function (othis) {
            var index = layer.open({
                type: 2,
                content: '{:url(\'Order/verifyInfo\')}?order_id=' + id+'&order_sn='+'{$order.order_sn}',
                area: ['70%', '80%'],
                maxmin: true
            });
            //layer.full(index);
        };

        //驳回退款
        admin.events.rejectRefund = function (othis) {
            layer.confirm('确定驳回退款吗？操作不可逆转', function(){
                layer.closeAll('dialog');
                admin.req({
                    url: '{:url(\'Order/rejectRefund\')}'
                    , type: 'post'
                    , data: {id:id}
                    , success: function (res) {
                        if(res.code==0){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                                window.location.reload();
                                //刷新父页面
                                parent.tableIn.reload();
                            });
                        }
                    }
                });
            });
        };

        //线下退款
        admin.events.offlineRefund = function (othis) {
            layer.confirm('确定线下退款吗？此操作仅更改退款状态，金额请线下联系买家退款', function(){
                layer.closeAll('dialog');
                admin.req({
                    url: '{:url(\'Order/offlineRefund\')}'
                    , type: 'post'
                    , data: {id:id}
                    , success: function (res) {

                        if(res.code==0){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                                window.location.reload();
                                //刷新父页面
                                parent.tableIn.reload();
                            });
                        }
                    }
                });
            });
        };

        //线上退款
        admin.events.onlineRefund = function (othis) {
            layer.confirm('确定线上退款吗？买家支付金额将原路退回', function(){
                layer.closeAll('dialog');
                admin.req({
                    url: '{:url(\'Order/onlineRefund\')}'
                    , type: 'post'
                    , data: {id:id}
                    , success: function (res) {
                        if(res.code==0){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                                window.location.reload();
                                //刷新父页面
                                parent.tableIn.reload();
                            });
                        }
                    }
                });
            });
        };

        //驳回换货
        admin.events.rejectChange = function (othis) {
            layer.confirm('确定驳回换货吗？操作不可逆转', function(){
                layer.closeAll('dialog');
                admin.req({
                    url: '{:url(\'Order/rejectChange\')}'
                    , type: 'post'
                    , data: {id:id}
                    , success: function (res) {
                        if(res.code==0){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                                window.location.reload();
                                //刷新父页面
                                parent.tableIn.reload();
                            });
                        }
                    }
                });
            });
        };

        //确认换货
        admin.events.confirmChange = function (othis) {
            var index = layer.open({
                type: 2,
                content: '{:url(\'Order/confirmChange\')}?id=' + id,
                area: ['50%', '80%'],
                maxmin: true
            });
            //layer.full(index);
        };
    });
</script>
</body>
</html>